/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sudoku;

import Modelo.SolucionTablero6x6;
import Modelo.Sugerir;
import db.ChargeDataBase;

/**
 *
 * @author sabrina
 */
public class SugerirController6x6V2 implements IController {
    
   private TableroSudoku6x6V2 tab;
   public static int [][] m = new int[6][6];

   IniciarNivel6x6V1 i; 
    
    
    public void process(String model){
      //armo matriz de acuerdo a lo que hay en los jtextfield
      int p=0;  
      for(int x=0; x<m.length;x++){ 
          for (int y=0; y<m[x].length;y++){
                String casillero = (String) tab.text1[p].getText();
                if (casillero.equals("")){
                    m[x][y]=Integer.parseInt("0");
                }else{
                m[x][y]=Integer.parseInt(casillero);
     }   
     p++;
    }
  }
          
   
   Sugerir sug = new Sugerir(m); 
   int[] a= sug.SugerirValor(m);
   m[a[0]][a[1]]=a[2];
   System.out.println(m[a[0]][a[1]]);
     int index=0;
       
       for(int z=0; z<m.length;z++){
          for (int y=0; y<m[0].length;y++){
               if(m[z][y]!=0)
                tab.text1[index].setText(((Integer)m[z][y]).toString());
              else
                  tab.text1[index].setText("");
                index++;
               }
       }
    
    tab.present("sugerencia exitosa");
    }
    public void setView(IView x) {
       this.tab = (TableroSudoku6x6V2) x;             
}
}